#include<iostream>
using namespace std;
int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int t1 = a * 60 + b;
	int t2 = c * 60 + d;
	int ans = t2 - t1;
	cout << ans << endl;
	return 0;
}